Kinetis SDK Demo Applications User Guide  1.0.0-beta
Freescale Semiconductor, Inc.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
shell.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 - 2014, Freescale Semiconductor, Inc.
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without modification,
6  * are permitted provided that the following conditions are met:
7  *
8  * o Redistributions of source code must retain the above copyright notice, this list
9  * of conditions and the following disclaimer.
10  *
11  * o Redistributions in binary form must reproduce the above copyright notice, this
12  * list of conditions and the following disclaimer in the documentation and/or
13  * other materials provided with the distribution.
14  *
15  * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
23  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #ifndef __shell_H__
31 #define __shell_H__
32 
33 #include <stdint.h>
34 #include <string.h>
35 #include <ctype.h>
36 
37 #include "shell_config.h"
38 
42 typedef struct
43 {
44  uint8_t (*sh_getc)(void);
45  void (*sh_putc)(uint8_t ch);
47 
48 #ifdef SHELL_CONFIG_USE_STDIO
49 #define shell_printf(fmt,args...) printf (fmt ,##args)
50 #endif
51 
52 typedef struct
53 {
54  char *name; /* Command Name */
55  uint8_t maxargs; /* maximum number of arguments */
56  uint8_t repeatable; /* autorepeat allowed? */
57  int (*cmd)(int argc, char * const argv[]); /* Implementation function */
58  char *usage; /* Usage message (short) */
59  char *help; /* Help message (long) */
60  int (*complete)(int argc, char * const argv[], char last_char, int maxv, char *cmdv[]); /* do auto completion on the arguments */
61 }cmd_tbl_t;
62 
63 typedef enum
64 {
65  CMD_RET_SUCCESS = 0, /* 0 = Success */
66  CMD_RET_FAILURE = 1, /* 1 = Failure */
67  CMD_RET_USAGE = -1, /* Failure, please report 'usage' error */
69 
71 uint8_t shell_register_function(const cmd_tbl_t * pAddress);
72 void shell_register_function_array(const cmd_tbl_t * pAddress, uint8_t num);
73 uint8_t shell_unregister_function(char * name);
74 int shell_printf(const char * format,...);
75 void shell_beep(void);
76 const cmd_tbl_t *shell_find_command (const char * cmd);
77 uint8_t shell_io_install(shell_io_install_t * IOInstallStruct);
78 const cmd_tbl_t ** shell_get_cmd_tbl(void);
79 char ** shell_get_hist_data_list(uint8_t * num, uint8_t * cur_index);
80 void shell_main_loop(char * prompt);
81 
82 #endif
83 
84 /*******************************************************************************
85  * EOF
86  ******************************************************************************/
87 
88 
Definition: shell.h:65
uint8_t shell_unregister_function(char *name)
unregister function
Definition: shell.c:288
void shell_beep(void)
beep consult
Definition: shell.c:225
char ** shell_get_hist_data_list(uint8_t *num, uint8_t *cur_index)
uint8_t maxargs
Definition: shell.h:55
char * help
Definition: shell.h:59
Access command structure.
Definition: cmd_handle.h:39
uint8_t shell_io_install(shell_io_install_t *IOInstallStruct)
install shell io function.
Definition: shell.c:204
int shell_printf(const char *format,...)
use vsprintf for format.
Definition: shell.c:188
uint8_t repeatable
Definition: shell.h:56
void shell_main_loop(char *prompt)
Definition: shell.c:797
uint8_t shell_register_function(const cmd_tbl_t *pAddress)
register a user function
Definition: shell.c:250
Definition: shell.h:67
Definition: shell.h:66
static sai_data_format_t * format
Definition: modulator.c:60
void shell_register_function_array(const cmd_tbl_t *pAddress, uint8_t num)
register function array
Definition: shell.c:276
command_ret_t
Definition: shell.h:63
const cmd_tbl_t * shell_find_command(const char *cmd)
find command form command struct&#39;s name
Definition: shell.c:772
Definition: shell.h:42
char * usage
Definition: shell.h:58
const cmd_tbl_t ** shell_get_cmd_tbl(void)
get global cmdstruct table address
Definition: shell.c:232